﻿using System;
using System.Collections.Generic;
using System.Text;

#region Copyright (c) 2006, 2007, 2008, 2009 Render Studio Foundation. All rights reserved.

/*
 Copyright (c) 2006, 2007, 2008, 2009 Render Studio Foundation. All rights reserved.
 This work is copyrighted in its entirety. Permission to use "Render Studio"
 material may be granted only after we receive a written request from you,
 and you receive written permission from us.

 While Render Studio Foundation provides the information herein to anyone,
 we retain copyright on all code, text, graphic images, and other content.
 This means that you may not distribute the code, the text or graphics to others without the
 express written permission of Render Studio Foundation; "mirror" this information on your server
 without our permission; or modify or reuse the code, text or graphics on our servers.
 You may print copies of the information for your own personal use; and, you may reference
 the Service from your own documents. Any commercial use of this material is prohibited without
 the written permission of Render Studio Foundation. In all copies of this information, you must
 retain this notice and any other copyright notices originally included with such information.

 This material may be protected by U.S. and International Copyright laws, and you are legally
 bound by the copyright notices on those systems.

 "Render Studio" logos and other official symbols or graphics may not be used in connection with any
 product or service that has not been expressly authorized in advance in writing or in any manner
 that is likely to cause confusion among the users of this or other Web sites or among the public.
 All other seals, graphics or trademarks of organizations not affiliated with Render Studio Foundation
 that appear on this site are the property of their respective owners.

 Render Studio Foundation reserve all other rights. 
*/

#endregion

#region Render Studio Source Code Licence

/*
This license governs use of the Render Studio software. If you use the software, you accept this license. If you do not accept the license, do not use the software.

1. Summary

The source code is made available to view for reference purposes or to contribute to the project only. Developers may not distribute or modify the code for commercial or non-commercial purposes without express Agreement of Render Studio Foundation.

2. Definitions

The terms "reproduce," "reproduction," and "distribution" have the same meaning here as under U.S. copyright law.
"Licensor" means the foundation "Render Studio Foundation".
"You" means the licensee of the software, who is not engaged in designing, developing, or testing other software, that has the same or substantially the same features or functionality as the software.
"Your company" means the company you worked for when you downloaded the software.
"Reference use" means use of the software within your company as a reference, in read only form, for the sole purposes of debugging and maintaining your products. For clarity, "reference use" does NOT include (a) the right to use the software for purposes of designing, developing, or testing other software, that has the same or substantially the same features or functionality as the software, and (b) the right to distribute the software outside of your company.
"Licensed patents" means any Licensor patent claims which read directly on the software as distributed by the Licensor under this license.

3. Grant of Rights

(A) Copyright Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free copyright license to reproduce the software for reference use.
(B) Patent Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free patent license under licensed patents for reference use.
4. Limitations
(A) No Trademark License- This license does not grant you any rights to use the Licensor's name, logo, or trademarks.
(B) If you begin patent litigation against the Licensor over patents that you think may apply to the software (including a cross-claim or counterclaim in a lawsuit), your license to the software ends automatically.
(C) The software is licensed "as-is." You bear the risk of using it. The Licensor gives no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the Licensor excludes the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
 */

#endregion

namespace RSEngine.Core
{

    /// <summary>
    /// Define a surface's color.
    /// </summary>
    public class ColorMap: Resource
    {

        #region Variables

        private Dictionary<string, string> _properties = null;

        public float[] RGBA = new float[4] { 0f, 0f, 0f, 1f };

        #endregion

        #region Constructor

        public ColorMap()
        {
            RGBA = new float[4] { 0f, 0f, 0f, 1f };
        }

        public ColorMap(float r, float g, float b, float a)
        {
            RGBA = new float[4] { r, g, b, a };
        }

        public ColorMap(float[] rgba)
        {
            if (rgba.Length == 4)
                RGBA = new float[4] { rgba[0], rgba[1], rgba[2], rgba[3] };
            else if (rgba.Length == 3)
                RGBA = new float[4] { rgba[0], rgba[1], rgba[2], 1f };
        }

        #endregion

        #region Properties

        /// <summary>
        /// Dynamic and generic properties.
        /// </summary>
        public Dictionary<string, string> Properties
        {
            get
            {
                if (_properties == null)
                    _properties = new Dictionary<string, string>(0);
                return _properties;
            }
        }

        /// <summary>
        /// Returns the default color.
        /// </summary>
        virtual public float[] DefaultColor
        {
            get
            {
                return RGBA;
            }
        }

        #endregion

        #region Load

        public override void Load()
        {
        }

        #endregion

        #region Clone

        /// <summary>
        /// Clone it.
        /// </summary>
        virtual public ColorMap Clone()
        {
            return new ColorMap(RGBA[0], RGBA[1], RGBA[2], RGBA[3]);
        }

        #endregion

    }

}
